﻿using Autodesk.Revit.Creation;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace demo
{
    [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
    [Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
    [Autodesk.Revit.Attributes.Journaling(Autodesk.Revit.Attributes.JournalingMode.NoCommandData)]
    public class Cube : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            Autodesk.Revit.DB.Document document = commandData.Application.ActiveUIDocument.Document;
            Transaction tran = new Transaction(document, "方块");
            tran.Start();
                DirectShape ds = DirectShape.CreateElement(document, new ElementId(BuiltInCategory.OST_GenericModel));
                var box = new EntityInfo();
            var solid = fangyang();// box.CreateBox(XYZ.Zero,25);
                ds.SetShape(new List<GeometryObject>() { solid });
            tran.Commit();
            return Result.Succeeded;
        }


        public Solid fangyang()
        {
           
            var profile = Profile.CreateRectangle(2,2);
            profile.InnerProfile= Profile.CreateRectangle(1.5, 1.5);
            CurveLoop path = new CurveLoop();
            path.Append(Line.CreateBound(new XYZ(0, 0, 0), new XYZ(10, 0, 0)));
            path.Append(Arc.Create(new XYZ(10,0,0),new XYZ(100,0,20),new XYZ(45,0,10)));

            return profile.CreateSweptGeometry(path, new SolidOptions(ElementId.InvalidElementId, ElementId.InvalidElementId));

        }




    }
}
